// Copyright 2017 Baidu Inc. All Rights Reserved.
// Author: tai xiurong (taixiurong@baidu.com)
//
// Description:

#include "baidu_recorder_manager.h"
#include "baidu_speex_encoder.h"
#include "baidu_media_adapter.h"
#include "heap_monitor.h"

namespace duer {


RecorderManager::RecorderManager(Recorder::IListener* listener)
	:_recorder(NEW(RECORDER) duer::MediaAdapter , 640)
{
	_recorder.set_listener(listener);
}

#if 0
RecorderManager::RecorderManager(Recorder::MiddleWare* midware) :
        _recorder(NEW(RECORDER) duer::MediaAdapter
#ifdef TARGET_UNO_91H
              , 640
#endif
             ),
        _midware(midware) {
    _recorder.set_listener(_midware);
}



RecorderManager::RecorderManager() :
        _recorder(NEW(RECORDER) duer::MediaAdapter
#ifdef TARGET_UNO_91H
              , 640
#endif
             ),
        _midware(NEW(RECORDER) SpeexEncoder) {
    _recorder.set_listener(_midware);
}
#endif

RecorderManager::~RecorderManager() {
    delete _midware;
}

int RecorderManager::start() {
    return _recorder.start();
}

int RecorderManager::resume() {
    return _recorder.resume();
}

int RecorderManager::pause() {
    return _recorder.pause();
}

int RecorderManager::stop() {
    return _recorder.stop();
}

int RecorderManager::set_listener(Recorder::IListener* listener) {
    if (_midware) {
        return _midware->set_listener(listener);
    }
    return -1;
}

}//duer

